let path = require('path')
let HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
    entry: "./src/index.js",
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'build.js'
    },
    plugins: [new HtmlWebpackPlugin({
        template: './public/index.html'
    })],
    module: {
        rules: [ //引入css文件  下载style-loader  css-loader  加载器
            {
                test: /\.css$/i,
                use: ["style-loader", "css-loader"],
            },
            {
                test: /\.(png|jpg|gif)$/i,
                use: [
                    {
                        loader: 'url-loader',
                        options: {
                            limit: 8192,  //limit的作用是:设置打包文件的大小,如果超过8字节,就直接放到/dist目录下
                            //如果小于8字节,就通过url-loader 打包为64base字符串图片格式              
                        },
                    },
                ],
            },
            {
                test: /\.(eot|svg|ttf|woff|woff2)$/i,
                use: [
                    {
                        loader: 'url-loader',
                        options: {
                            limit: 8192,  //limit的作用是:设置打包文件的大小,如果超过8字节,就直接放到/dist目录下
                            //如果小于8字节,就通过url-loader 打包为64base字符串图片格式              
                        },
                    },
                ],
            },
            {
                test: /\.m?js$/,  //识别js文件和mjs文件
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            }
        ],
    },
    // mode: "development",
    // devtool: "cheap-module-source-map"
    mode: "production",
    devtool: "source-map"
}